package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Customer;
import com.atguigu.jxc.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("customer")
public class CustomerController {

    @Autowired
    private CustomerService customerService;

    @PostMapping("/list")
    //客户列表分页
    public Map<String, Object> customerList(Integer page, Integer rows, String customerName){

        return customerService.getCustomerList(page,rows,customerName);
    }

    @PostMapping("save")
    public ServiceVO saveOrUpdateCustomer(Customer customer){
        return customerService.saveOrUpdateCustomer(customer);

    }

    @PostMapping("delete")
    public ServiceVO deleteCustomer(String ids){
        return customerService.deleteCustomer(ids);
    }
}
